<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    let url = 'https://juejin.cn/post/6946022649768181774?utm_campaign=sembaidu&utm_medium=sem_baidu_jj_pc_dc01&utm_source=bdpcjj00225#heading-0&wd=%E7%99%BE%E5%BA%A6'
    
    //方法一
    let arr = url.slice(url.indexOf("?")+1).split("&")
    var obj = {}
    for (let i = 0; i < arr.length; i++) {
      let [key,val] = arr[i].split("=")
      val = decodeURIComponent(val)
      obj[key] = val
    }
    console.log(obj)

    //方法二
    const q = {};
    url.replace(/([^?&=]+)=([^&]+)/g, (_,k,v) => {q[k]=decodeURIComponent(v)});
    console.log(q);
    
  </script>
</body>
</html>